//
//  LatterInfoViewController.m
//  QianJinDai
//
//  Created by wangzijian on 15/10/22.
//  Copyright (c) 2015年 xuxuan. All rights reserved.
//

#import "LatterInfoViewController.h"

#import "EmptyDataView.h"

@interface LatterInfoViewController ()

@end

@implementation LatterInfoViewController
{
    AFHTTPRequestOperationManager *_manager;
}

- (void)viewDidLoad
{ 
    [super viewDidLoad];
    _manager = [AFHTTPRequestOperationManager manager];
     [self initDate];
    // Do any additional setup after loading the view from its nib.
}
- (void)initDate{
    NSString *url=[NSString stringWithFormat:@"%@Letter/GetLetterDetail",BaseURL];
    NSDictionary *parameters = @{@"letterid":_lid,@"memberletterid":_mlid,@"memberid":Getmemberid,@"signature":[Util getSignature:[NSString stringWithFormat:@"%@%@%@",_lid,_mlid,Getmemberid]]};
    AFHTTPRequestOperation*op= [_manager POST:url parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
    NSError*error;
    NSDictionary *dic=[NSJSONSerialization JSONObjectWithData:responseObject options:NSJSONReadingAllowFragments error:&error];
    //NSLog(@"%@",dic);
    NSDictionary *result = [dic valueForKey:@"Data"];
        NSLog(@"%@",result);
    if (error==nil && [[dic valueForKey:@"Status"] isEqualToNumber:@1]) {
        
        _time.text= [Util getDateTime:[result valueForKey:@"Letter_CreateDate"]];
        _titleHead.text =[result valueForKey:@"Letter_title"];
//        _content.text =[NSString stringWithFormat:@"        %@",[result valueForKey:@"Letter_content"]];
        NSString*c =[[[result valueForKey:@"Letter_content"] stringByReplacingOccurrencesOfString:@"\\n" withString:@"\n"]stringByReplacingOccurrencesOfString:@"\\t" withString:@"\t"];
        _content.text =c;

    }else{
        EmptyDataView *view = [[EmptyDataView alloc] initWithEmptyTitle:@"暂无消息"];
        view.top = 70;
        [self.view addSubview:view];
    }

    
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
    [[[UIAlertView alloc] initWithTitle: @"网络异常" message:nil delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil, nil] show];
}];
op.responseSerializer = [AFCompoundResponseSerializer serializer];
[op start];
}
@end